#
# This file is a part of the open-eBackup project.
# This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
# If a copy of the MPL was not distributed with this file, You can obtain one at
# http://mozilla.org/MPL/2.0/.
#
# Copyright (c) [2024] Huawei Technologies Co.,Ltd.
#
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
#

import stat
from enum import Enum

from common.const import PathConstant
from common.env_common import get_install_head_path, get_informix_install_path, get_gbase_install_path

PERMISSION_755 = stat.S_IRWXU | stat.S_IXGRP | stat.S_IRGRP | stat.S_IROTH | stat.S_IXOTH
PERMISSION_700 = stat.S_IRWXU
PERMISSION_555 = stat.S_IRUSR | stat.S_IXUSR | stat.S_IRGRP | stat.S_IXGRP | stat.S_IROTH | stat.S_IXOTH
PERMISSION_600 = stat.S_IRUSR | stat.S_IWUSR
PERMISSION_640 = stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP
PERMISSION_644 = stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH

# cp工具单次备份最大文件数量
MAX_FILE_NUMBER_OF_LOG_BACKUP = 1000


class InformixBaseCommand:
    QUERY_STATUS = "onstat -l"
    QUERY_CLUSTER_BOUND_NODE = "onstat -g dri"
    RESTORY_PHYSIC = 'onbar -r -p >> {}'
    RESTORY_TIMESTEP = 'onbar -r -t {} >> {}'
    RESTORY_LOGIC = 'onbar -r -l >> {}'
    SWITCH_TO_ONLINE = 'onmode -m'
    BACKUP = "onbar -b -p -L {} >> {}"
    BACKUP_WITH_LOG = "onbar -b -L {} >> {}"
    SET_BAR_BSALIB_PATH_ENV = (f"onmode -wf BAR_BSALIB_PATH={PathConstant.XBSA_PATH}/lib/libxbsa64iif.so")
    SET_BAR_IXBAR_PATH_ENV = "onmode -wf BAR_IXBAR_PATH={}"
    SET_ALARMPROGRAM_ENV = "onmode -wf ALARMPROGRAM={}"
    ADD_BACKUP_FILE_DEVICE = "onpsm -D add {} -g {} -p {} -t FILE"
    DEL_BACKUP_FILE_DEVICE = "onpsm -D del {} -g {} -y"
    GEN_CATALOG_TABLE = "cd {};onpsm -C export"
    ENTER_DATABASE = "isql -v {}"
    QUERY_COPY_HISTORY_SQL = \
        "select ins_aid,ins_oid from bar_instance where ins_first_log!=0 and ins_level={} order by ins_aid desc limit 1"
    COMMAND_CONNECTION = ";"
    ECHO_TARGET_ENV = "echo ${}"
    QUERY_OLD_FILE_DEVICE = "onpsm -D list"
    EXEC_WITH_INFORMIX = 'su - informix -c {}'
    EXEC_WITH_INFORMIX_WITH_QUOTATION = 'su - informix -c "{}"'
    REBUILD_SECONDARY_NODE_LINUX = 'ontape -s -L -0 -t STDIO -F | rsh {} ' \
                                   '\\"source ~/.bash_profile;ontape -p -t STDIO\\"'
    REBUILD_SECONDARY_NODE_AIX = 'ontape -s -L -0 -t STDIO -F | rsh {} \\". ~/.profile;ontape -p -t STDIO\\"'
    SET_PAIMARY = "onmode -d primary {}"
    SET_SECONDARY = "onmode -d secondary {}"
    ENV_CMD = 'export INFORMIXSERVER={} ONCONFIG={} INFORMIXSQLHOSTS={}; {}'
    ARCH_CURRENT_LOG = "onbar -b -l -c"
    FROCE_NEXT_LOGICAL_LOG = "onmode -l"
    UP_SECONDARY_AIX = 'rsh {} ". ~/.profile;onmode -d secondary {}"'
    UP_SECONDARY_LINUX = 'rsh {} "source ~/.bash_profile;onmode -d secondary {}"'
    INFORMIX_VERSION = "onstat -version"
    CLEAN_INSTANCE = "onclean -ky"


class GbaseCommand:
    QUERY_VERSION = 'onstat -V'
    QUERY_STATUS = "onstat -l"
    EXEC_WITH_GBASEDBT = "su - gbasedbt -c {}"
    ENV_CMD = 'export GBASEDBTSERVER={} ONCONFIG={} GBASESQLHOSTS={}; {}'
    EXEC_WITH_GBASEDBT_WITH_QUOTATION = 'su - gbasedbt -c "{}"'
    STOP_COMMAND = 'onmode -ky'
    START_COMMAND = 'oninit -vy'


class MountType:
    FUSE = 'fuse'


class EnvNameValue:
    IAM_OSADAUTHPORT = "job_extendInfo_OSADAuthPort"


class PathInfo:
    XBSA_META_PATH = f'{get_install_head_path()}/DataBackup/meta/1'
    XBSA_TMP_PATH = f'{get_install_head_path()}/DataBackup/tmp/1/'


class FileConstant:
    HOSTSN_FILE = "/etc/HostSN/HostSN"
    BACKUP_BASE_DIR = f"{get_install_head_path()}/DataBackup/informix"
    FILE_DEVICE = "FILE_DEVICE"
    BACKUP_JSON_FILE = "backup_record.json"
    INFORMIX_FILE_DEVICE = "file_device.txt"
    BACKUP_FILE_DEVICE = [["HIGHEST", "DBSPOOL", BACKUP_BASE_DIR], ["HIGHEST", "LOGPOOL", BACKUP_BASE_DIR]]
    INFORMIX_FILESYSTEM_MOUNT_PATH = "/mnt/databackup"
    AGENT_STMP_PATH = f"{get_install_head_path()}/DataBackup/ProtectClient/ProtectClient-E/stmp"
    AGENT_CONF_PATH = f"{get_install_head_path()}/DataBackup/ProtectClient/ProtectClient-E/conf"
    DATABACKUP_PATH = f"{get_install_head_path()}/DataBackup/"
    INFORMIX_PATH = f"{get_informix_install_path()}"
    INFORMIX_HOME_PATH = "/home/informix"
    GBASE_PATH = f"{get_gbase_install_path()}"
    GBASE_HOME_PATH = "/home/gbasedbt"
    GBASE_BACKUPS_PATH = f'{get_gbase_install_path()}/backups'
    WHITE_FILE_LIST = [
        INFORMIX_FILESYSTEM_MOUNT_PATH, BACKUP_BASE_DIR, AGENT_STMP_PATH, DATABACKUP_PATH, INFORMIX_PATH,
        PathConstant.XBSA_PATH, INFORMIX_HOME_PATH, GBASE_PATH, GBASE_HOME_PATH, GBASE_BACKUPS_PATH
    ]
    JSON_SCHEMA_PATH = "informix/jsonschema/informix_define.json"


class SqlConstant:
    Query_LOG_RECORDS = "select objectName from BsaObjTable where resourceType='L'"
    DELETE_LOG_RECORD = "delete from BsaObjTable where objectName='{}'"


class AllStepEnum(str, Enum):
    CHECK_APPLICATION = "CheckApplication"
    SUPPORT_RESOURCE = "ListApplicationResource"
    ALLOW_BACKUP_IN_LOCAL_NODE = "AllowBackupInLocalNode"
    QUERY_JOB_PERMISSION = "QueryJobPermission"
    CHECK_BACKUP_JOB_TYPE = "CheckBackupJobType"
    PRE_TASK = "BackupPrerequisite"
    BACKUP_GEN_SUB = "BackupGenSubJob"
    BACKUP = "Backup"
    QUERY_SCAN_REPOSITORIES = "QueryScanRepositories"
    POST_TASK = "BackupPostJob"
    STOP_TASK = "AbortJob"

    QUERY_BACKUP_COPY = "QueryBackupCopy"
    GENERATOR_SUB_JOB = "GeneratorSubJob"
    QUERY_CLUSTER = "QueryCluster"
    RESTORE_PREREQUISITE = "restore_pre"
    CLUSTER_RESTORE_PREREQUISITE = "cluster_restore_pre"
    ALLOW_RESTORE = "AllowRestoreInLocalNode"
    RESTORE = "restore_exec_sub"
    RESTORE_POST = "restore_post"
    DELETECOPY = "DelCopy"
    CHECK_COPY = "CheckCopy"
    DELIVE_TASK_STATUS = "DeliverTaskStatus"
    RESTORE_GEN_SUB = "restore_gen_sub"
    REMOVE_PROTECT = "RemoveProtect"


class RegisterType(int, Enum):
    ERR_TYPE = 0
    SINGLE = 1
    CLUSTER = 2


class DeployType:
    # 单节点
    SINGLE = '1'
    # 双主
    AA = '2'
    # 主备
    AP = '3'
    # 共享
    SHARDING = '4'
    # 分布式
    DISTRIBUTED = '5'


class BackupStatus:
    COMPLETED = 1
    RUNNING = 2
    FAILED = 3


class ErrorCode(int, Enum):
    ERROR_INCREMENT_TO_FULL = 1577209901
    ERROR_DIFFERENT_VERSION = 1577209971
    ERROR_DIFFERENT_TOPO = 1577209972
    ERROR_DIFFERENT_USER = 1577209973
    ERROR_MOUNT_PATH = 1577209974
    ERR_DATABASE_STATUS = 1577210000
    ERROR_USER_NOT_EXIST_CLUSTER = 0x5E0250D7
    ERR_RESTORED = 1577210101
    # 某个服务未正常开启，返回参数 服务名称
    ERROR_SERVICE_1577213479 = 1577213479
    # 数据库不存在，返回参数 数据库名称
    ERROR_DB_NOT_EXIST = 1577213477
    # 认证信息错误
    ERROR_AUTH = 1577209942
    # 参数错误
    ERROR_PARAM = 1677929218
    SYSTEM_ID_NOT_EXIST = 0
    DB_NODES_NOT_FULL_MATCH = 1677931026
    DB_ENV_ERROR = 2
    ACCESS_DB_ERROR = 3
    TENANT_MODEL_NOT_SUPPORT = 4
    # 集群不在线
    CLUSTER_NOT_ONLINE = 5
    # 不允许更换保护的数据库
    NOT_ALLOW_CHANGE_PROTECT_DB = 6
    # 不能修改数据库为新的数据库
    NOT_ALLOW_CHANGE_DB_TO_NEW_DB = 7
    # 不能修改数据库为新的数据库
    ERR_RENAME_DATABASE = 1577213482
    # 系统异常
    SYSTEM_ERROR = 1677929221
    # 不是所有数据库的服务都运行
    NOT_ALL_DB_SERVICE_RUNNING = 9
    # 增量转全量
    INC_TO_FULL = 0x5E02502D
    # 数据库不存在
    ERR_DB_NOT_EXIST = 1577210047
    # 部署类型错误
    ERR_DEPLOY_TYPE = 0x5E02508B
    # 版本不支持
    ERR_NOT_SUPPORT_VERSION = 1677935120
    # 数据库环境异常不支持备份恢复
    ERR_ENVIRONMENT = 1577213475
    # 账号密码错误
    LOGIN_FAILED = 1677929488
    # 数据库服务异常
    ERR_DB_SERVICES = 1577213479
    # 输入参数错误
    ERR_INPUT_STRING = 1677934101
    # 主机选择有误
    ERR_CHOSEN_HOSTS = 1577209936
    # vc名称设置有误
    ERR_VC_NAME_WRONG = 1577209940

    ERR_USERNAME_OR_PASSWORD = 1577209938
    ERR_VC_NEEDED = 1577209941
    OPERATE_FAILED = 1677929219
    DB_NOT_RUNNING = 1577084161

    # 存在gcrcman运行进程 待基线
    PROCESS_EXISTED = 9
    PATH_NOT_FOUND = 10

    MY_SUCCESS_CODE = 0
    MY_ERROR_CODE = 1
    TURN_TO_FULL = 2

    # 执行日志备份操作时，由于数据库未新生成日志，操作失败。
    ERROR_NO_LOG_CREATE = 1577284374
    # 执行备份操作时，由于解除日志备份路径挂载失败，操作失败。
    ERROR_UMOUNT_LOG_PATH = 1577284373

    # 错误场景：执行数据库的数据备份操作失败。
    # 原因：执行数据库的数据备份操作失败。
    # 建议：请联系技术支持工程师协助处理。
    BACKUP_DB_FAIL = 1627607814

    # 集群节点不允许注册单实例。
    ERROR_CLUSTER_NODE_NOT_ALLOW_REGISTER_SINGLE_INS = 1577213523
    # 单机节点不允许注册集群实例。
    ERROR_SINGLE_NODE_NOT_ALLOW_REGISTER_CLUSTER_INS = 1577213535

    # 待申请的错误码
    ERROR_SQLHOSTS_FILE_NOT_EXIST = 1577284362
    ERROR_ONCONFIG_FILE_NOT_EXIST = 1577284363
    ERROR_INSTANCE_NOT_EXIST = 1577284364
    ERR_DB_IS_RUNNING = 1577210048
    DB_ARCH_NOT_OPEN = 1577209998
    ERR_INVALID_LOG_COPY = 1577209918
    ERR_ROOT_DB_FILE_INCONSISTENCY = 1577284365
    DB_NOT_EXIST = 1577213477
    ERR_LOG_BACKUP_START_FAIL = 1577284375
    ERR_DB_NOT_CONFIG_XBSA = 1677876738

    # 注册集群开启日志备份但日志备份路径不符合要求
    ERR_LOG_BACKUP_PATH = 1577212933
    # 执行备份/恢复命令失败
    EXEC_BACKUP_RECOVER_CMD_FAIL = 1577209989


class JsonConstant(str, Enum):
    ONCONFIG_PATH = "onconfigPath"
    SQLHOSTS_PATH = "sqlhostsPath"
    SUBTYPE = "subType"
    IP = "ip"
    INFORMIX_SINGLE_INSTANCE = "Informix-singleInstance"
    INFORMIX_CLUSTER_INSTANCE = "Informix-clusterInstance"
    REPORITORYTYPE = "repositoryType"
    PAIREDSERVER = "pairedServer"
    INFORMIX_SERVICE = "Informix-service"
    LOG_BACKUP = "logBackup"
    LOG_BACKUP_PATH = "logBackupPath"
    TARGET_LOCATION = "targetLocation"
    SERVER_NUM = "serverNum"
    SERVERNUM = "servernum"
    LOCALSERVER = "localServer"
    HOSTSN_FILE_PATH = "/etc/HostSN/HostSN"
    INSTANCE_STATUS = "instanceStatus"
    LOG_BACKUP_KEY = "logBackup"
    STATUS = "status"
    COPY_ID_LIST = 'copyIdList'
    AUTH_CUSTOM_PARAMS = "authCustomParams"
    APP_ENV = "appEnv"
    JOB_INFO = "jobInfo"
    JOB_PRIORITY = "jobPriority"
    JOB_TYPE = "jobType"
    HOSTS = "hosts"
    POLICY = "policy"
    SUB_JOB_ID = "subJobId"
    BASE_COPY_ID = "baseCopyId"
    CLUSTER_INFO = "cluster_info"
    CUSTOM_PARAMS = "customParams"
    DEPENDENCIES = "dependencies"
    CLUSTER_UUID = "clusterUuid"
    ORIGIN_PROTECT_ENV = "originProtectEnv"
    ORIGIN_PROTECTED_ENV = "originProtectedEnv"
    PROTECT_DATABASE = "database"
    SYSTEM_DB_USER = "systemDbUser"
    SYSTEM_DB_PASSWORD = "systemDbPassword"
    SYSTEM_ID = "systemId"
    APPLICATION_VERSION = "applicationVersion"
    SYSTEM_DB_PORT = "systemDbPort"
    EXTEND_INFO = "extendInfo"
    CLUSTER_TYPE = "clusterType"
    JOB = "job"
    JOB_PARAM = "jobParam"
    BACKUP_TYPE = "backupType"
    PROTECT_OBJECT = "protectObject"
    SUB_TYPE = "subType"
    PROTECT_ENV = "protectEnv"
    PROTECTED_ENV = "protectedEnv"
    ENDPOINT = "endpoint"
    AUTH = "auth"
    AUTH_KEY = "authKey"
    AUTH_PWD = "authPwd"
    INSTANCE_PORT = "instancePort"
    INSTANCE_NAME = "instance_name"
    NODES = "nodes"
    REPOSITORIES = "repositories"
    BASE_BACKUPSET = "base_backupset"
    REPOSITORY_TYPE = "repositoryType"
    PATH = "path"
    REMOTE_PATH = "remotePath"
    REMOTE_HOST = "remoteHost"
    BACK_JOB_RESULT = "backupJobResult"
    COPY = "copy"
    COPY_ID = "copyId"
    TIMESTAMP = "timestamp"
    BACKUP_TIME = "backupTime"
    BACKUP_LIMIT = "BackupLimit"
    NAME = "name"
    ROOTDBS_PATH = "rootdbsPath"
    COPIES = "copies"
    TARGET_OBJECT = "targetObject"
    RESTORE_JOB = "restoreType"
    RESTORE_JOB_RESULT = "restoreJobResult"
    PROGRESS = "progress"
    TASK_ID = "taskId"
    SUB_TASK_ID = "subTaskId"
    TASK_STATUS = "taskStatus"
    DATA_SIZE = "dataSize"
    SPEED = "speed"
    LOG_DETAIL = "logDetail"
    APPLICATION = "application"
    APPLICATIONS = "applications"
    LIVE_MOUNT = "liveMount"
    TARGET_ENV = "targetEnv"
    ROLE = "role"
    ADVANCE_PARAMS = "advanceParams"
    SUB_JOB = "subJob"
    JOB_NAME = "jobName"
    RESTORE_TIMESTAMP = "restoreTimestamp"
    TYPE = "type"
    TYPES = "types"
    MOUNT_JOB_ID = "mountJobId"
    LOG_INFO = "logInfo"
    LOG_INFO_PARAM = "logInfoParam"
    LOG_LEVEL = "logLevel"
    BACKUP_TASK_SLA = "backupTask_sla"
    POLICY_LIST = "policy_list"
    EXT_PARAMETERS = "ext_parameters"
    CHANNEL_NUMBER = "channel_number"
    NEW_DATABASE_NAME = "newDatabaseName"
    VERSION = "version"
    DATA_DIR = "dataDir"
    AVERAGE_SPEED = "averageSpeed"
    LOG_FLAG = "logFlag"
    LOG_FLAG_START_TIME = "logFlagStartTime"
    RESTORE_COPY_ID = "restoreCopyId"
    SERVICE_NAME = "serviceName"
    ID = "id"
    PARENTID = "parentId"
    BACKUP_HOST_SN = "backupHostSN"
    FIRST_FULL_BACKUP_TIME = "firstFullBackupTime"
    NEXT_CAUSE_PARAM = "next_cause_param"
    HOST_AGENT = "hostAgent"
    BACKUP_ID = "backupId"
    MULTI_TENANT_SYSTEM = "multiTenantSystem"
    IS_LOCAL = "isLocal"
    AGENT_IP_LIST = "agentIpList"
    JOB_ID = "jobId"
    POINT = "point"
    CYCLE = "cycle"
    AGENT_MOUNT_TYPE = "agentMountType"


class NormalErr(int, Enum):
    NO_ERR = 0
    FALSE = -1
    WAITING = -2


class RpcParamKey:
    APPLICATION = "application"
    TYPES = "types"
    FULL_COPY = "full"
    LOG_COPY = "log"
    INCREMENT_COPY = "increment"
    DIFF_COPY = "diff"
    COPY_ID = "copyId"
    INPUT_FILE_PREFFIX = "rpcInput_"
    OUTPUT_FILE_PREFFIX = "rpcOutput_"
    QUERY_PREVIOUS_CPOY = "QueryPreviousCopy"
    REPORT_JOB_DETAILS = "ReportJobDetails"
    REPORT_COPY_INFO = 'ReportCopyAdditionalInfo'
    TAPE_ARCHIVE = "tapeArchive"
    S3_ARCHIVE = "s3Archive"
    # 查询脚本
    RPC_TOOL = f"{get_install_head_path()}/DataBackup/ProtectClient/Plugins/GeneralDBPlugin/bin/rpctool.sh"
    # 输入参数文件目录
    PARAM_FILE_PATH = f"{get_install_head_path()}/DataBackup/ProtectClient/Plugins/GeneralDBPlugin/tmp"
    # 输出结果文件目录
    RESULT_PATH = f"{get_install_head_path()}/DataBackup/ProtectClient/Plugins/GeneralDBPlugin/stmp"
    # bin目录
    BIN_PATH = f"{get_install_head_path()}/DataBackup/ProtectClient/Plugins/GeneralDBPlugin/bin"


class SubJobPriority(int, Enum):
    JOB_PRIORITY_1 = 1,
    JOB_PRIORITY_2 = 2,
    JOB_PRIORITY_3 = 3,
    JOB_PRIORITY_4 = 4,


REPORT_INTERVAL_SEC = 30


class StatusOrVersion:
    STATUS = "status"
    VERSION = "version"


class GbaseInfo:
    GBASE_USER = "gbasedbt"


class InformixInfo:
    INFORMIX_USER = "informix"
    INFORMIX_VERSION_PREFIX = "IBM Informix Dynamic Server Version"
    SERVERNUM = "SERVERNUM"
    RDADMIN = 'rdadmin'
    BAR_BSALIB_PATH = "BAR_BSALIB_PATH"
    OBJECTMEAT = "objectmeta"


class InformixCustomParmConstant:
    INSTANCE_NAME = "instancename"
    CONFIG_PATH = "onconfigpath"
    CONFIG_NAME = "onconfigname"
    SQLHOSTS_PATH = "sqlhostspath"
    DB_IDENTIFIER = "odbc"
    CUSTOM_PARAMS_LIST = [INSTANCE_NAME, CONFIG_PATH, SQLHOSTS_PATH, DB_IDENTIFIER]


class GbaseExportCmdConstant:
    GBASE_SERVER = "GBASEDBTSERVER"
    ONCONFIG = "ONCONFIG"
    GBASE_SQLHOSTS = "GBASESQLHOSTS"


class InformixExportCmdConstant:
    INFORMIX_SERVER = "INFORMIXSERVER"
    ONCONFIG = "ONCONFIG"
    INFORMIX_SQLHOSTS = "INFORMIXSQLHOSTS"


class InformixVersion:
    informix_version = ""


class GbaseVersion:
    gbase_vesion = ""


class InformixInstanceStatus:
    ON_LINE_SINGLE = "On-Line"
    ON_LINE_CLUSTER_MASTER_NODE = ["On-Line (Prim)", "Quiescent (Prim)"]
    ON_LINE_CLUSTER_STANDBY_NODE = "Read-Only (Sec)"


class BackupType:
    FULL = "full"
    DIFF = "difference_increment"
    INCR = "cumulative_increment"
    LOG = "log"
    BACKUP_TYPE_DICT = {
        1: 0,
        2: 2,
        3: 1
    }


class SubJobType(int, Enum):
    PRE_SUB_JOB = 0,
    GENERATE_SUB_JOB = 1,
    BUSINESS_SUB_JOB = 2,
    POST_SUB_JOB = 3


class SubJobPolicy(int, Enum):
    LOCAL_NODE = 1,
    EVERY_NODE_ONE_TIME = 2,
    RETRY_OTHER_NODE_WHEN_FAILED = 3,
    FIXED_NODE = 4


class SubJobName:
    PRI_PRE_JOB = "primary_pre_job"
    SEC_PRE_JOB = "secondary_pre_job"
    ORIGINAL_RESTORE = "original_restore_job"
    SET_PRIMARY = "set_primary"
    START = "start"
    NEW_RESTORE = "new_restore_job"
    SET_SECONDARY = "set_secondary"


class LastCopyType:
    last_copy_type_dict = {
        2: [RpcParamKey.DIFF_COPY, RpcParamKey.FULL_COPY],
        3: [RpcParamKey.FULL_COPY],
        1: [RpcParamKey.DIFF_COPY],
        5: [RpcParamKey.FULL_COPY, RpcParamKey.INCREMENT_COPY, RpcParamKey.DIFF_COPY, RpcParamKey.LOG_COPY]
    }


class InformixPath:
    AGENT_STEMP_PATH = f'{get_install_head_path()}/DataBackup/ProtectClient/ProtectClient-E/stmp'
    LIB_XBSA_PATH = f"{PathConstant.XBSA_PATH}/lib/libxbsa64iif.so"
    LOG_BACKUP_TOOL_PATH = "etc/log_full.sh"


class ActionCode(int, Enum):
    SUCCESS = 0
    FAILED = -1
    WAITING = -2


ON_LINE_CLUSTER = ["On-Line (Prim)", "Read-Only (Sec)", "Quiescent (Sec)", "Quiescent (Prim)", "Updatable (Sec)"]
ON_LINE_SINGLE = ["On-Line", "Quiescent"]
# On-Line (CKPT REQ)状态允许资源注册，不允许备份
REOURCE_ON_LINE_SINGLE_STATS = ["On-Line", "Quiescent", "On-Line (CKPT REQ)"]
BACKUP_THREAD_NUM = 256
BACKUP_MAX_MEMORY = 104857600
BACKUP_TOOL_PARAM = {
    "job_id": "",
    "files": [],
    "destination": "",
    "write_meta": False,
    "thread_num": BACKUP_THREAD_NUM,
    "max_memory": BACKUP_MAX_MEMORY
}
